------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:/Users/silvio/Documents/CVR/ryp/output/s2_desc_mi.log
  log type:  text
 opened on:   4 Jul 2018, 12:57:42

. clear

. 
. use "${data}/mult_impu", clear

. set matsize 1392

. 
. la var perpe "Perpetrator"

. label def perpel 1 "EST"  2 "SLU" 3 "OTH"

. label values perpe perpel

. 
. 
. reshape long y, i(n) j(mi)
(note: j = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20)

Data                               wide   ->   long
-----------------------------------------------------------------------------
Number of obs.                     1392   ->   27840
Number of variables                  24   ->       6
j variable (20 values)                    ->   mi
xij variables:
                          y1 y2 ... y20   ->   y
-----------------------------------------------------------------------------

. 
. sort perpe

. by perpe: g ysum=sum(y)

. by perpe: keep if _n==_N
(27837 observations deleted)

. replace ysum=ysum/20
(3 real changes made)

. g ysumrel=100*ysum/(ysum[1]+ysum[2]+ysum[3])

. g ysumtot=ysum[1]+ysum[2]+ysum[3]

. list perpe ysum ysumtot ysumrel 

     +---------------------------------------+
     | perpe       ysum   ysumtot    ysumrel |
     |---------------------------------------|
  1. |   EST   10907.55     21254   51.31998 |
  2. |   SLU    10132.7     21254   47.67432 |
  3. |   OTH     213.75     21254   1.005693 |
     +---------------------------------------+

. 
. export excel perpe ysum ysumtot ysumrel using "$excel/${name}.xls", sheet("res") sheetmodify firstrow(varlabels) missing("."
> )
file C:/Users/silvio/Documents/CVR/ryp/excel/s2_desc_mi.xls saved

. 
. clear

. capture log close
